Skip to content

fix(studio): sealed keyframe edits save the same values as a regular preview - #8668

Merged
miguel-heygen merged 2 commits into
mainfrom
fix/studio-sealed-gsap-reads
Nov 24, 2026
Merged

miguel-heygen merged 2 commits into
mainfrom
fix/studio-sealed-gsap-reads

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What

Adding a keyframe from the Design panel in a sealed preview now saves the same keyframe as in a regular preview. Before, it also copied the element's corner radius (and any other value another tween animates) into every keyframe of the edited tween, which froze that value for the whole tween.

Why

To fill in a keyframe, Studio reads the element's current GSAP values. For values like borderRadius, fontSize or strokeWidth, it keeps one only when GSAP's value differs from the element's computed CSS, so it never writes a value the stylesheet already gives.

A regular preview reads that CSS from the frame's own document. A sealed preview has no document Studio can reach, so the comparison value was always missing and every such value counted as "differs". On a box that rotates in one tween and rounds its corners in another, one rotation keyframe added at 1 s saved borderRadius: 12 and all four corner longhands into the rotation tween's keyframes. That overrides the corner tween, so the corners stop animating. A regular preview saves only the rotation.

The read also ran without waiting for the sealed frame's GSAP values at the playhead. Right after a seek, the read could find nothing and the keyframe got no values from GSAP at all.

Related work

Refs #7846 (Studio's preview sealed by default): one of the sealed readers that must give the same result as a regular preview.

How

  • hooks/gsapRuntimeReaders.ts: readAllAnimatedProperties is now async.
    • It first waits for the sealed frame's GSAP values at the paused playhead (settleGsapSnapshot, as editsPlainCssSettled does).
    • It reads the computed CSS for the comparison through the frame's port (previewComputedStyles), the same read the property panel uses for a sealed element (components/editor/previewSelection.ts:374). A regular preview still reads getComputedStyle on its own element.
  • hooks/useAnimatedPropertyCommit.ts: its only caller, commitKeyframeProps, awaits it.

Test plan

  • New real-Chrome test src/hooks/gsapSealedReads.browser.test.ts: the runtime and GSAP in a sealed frame and in a same-origin one. In both, a rotation commit's read of the box returns only { rotation: 10 }. HF_PARITY_MODE=sealed|unsealed runs one mode.
  • fails without the fix: a rotation commit reads only the rotation tween's channels (sealed) in src/hooks/gsapSealedReads.browser.test.ts failed on main with borderRadius, borderTopLeftRadius, borderTopRightRadius, borderBottomLeftRadius and borderBottomRightRadius all 12 next to rotation: 10. The unsealed case passed on main.
  • On the devbox with the fix: the new test, gsapRuntimeReaders.test.ts and useAnimatedPropertyCommit.test.tsx, 3 runs each, green. All 24 Studio test files that cover the changed files, green. tsc, Fallow and the pre-push hooks clean.
  • Real app: Studio's dev server on the devbox, sealed (VITE_STUDIO_OPAQUE_PREVIEW_ENABLED=true) and regular, with a fixture project (a box with a keyframed rotation tween and a separate borderRadius tween). Select the box at 00:01, add a rotation keyframe from the Design panel, then read index.html:
sealed regular
main rotation keyframes carry borderRadius: 12 and four corner longhands rotation only
this branch rotation only rotation only

Before

Sealed preview on main, the saved timeline after adding the rotation keyframe:

Sealed preview on main: rotation keyframes carry borderRadius and four corner longhands

After

Sealed preview on this branch, the saved timeline:

Sealed preview on this branch: rotation keyframes carry only rotation

Studio after the edit, sealed, on this branch (the keyframe at 00:01 on the Rotation lane, angle 10°):

Sealed Studio after adding the rotation keyframe at 00:01

Regular preview on this branch, for comparison (same save as on main):

Regular preview on this branch: rotation only

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 273 (base branch 271), smooth 58 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Newly passing (2)

  • seqscaletwice-scale-px-r0-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)

  • seqscaletwice-scale-px-r0-nested-z100
  • seqscaletwice-scale-px-r0-root-z100

Quarantined, measured but not gated (0)

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 29d4556.

  • fails without the fix: checked. With both source files reverted to the merge-base, the sealed test fails with borderRadius: 12. The 3 test files pass 20/20 at head, and tsc is clean.
  • The baseline read: the CSS baseline now comes through previewComputedStyles, so sealed and unsealed compare GSAP's value against the same CSS. Only the 15 baseline properties used the empty read. Rotation, scale and opacity come from the tween. Per-corner radius is covered, and so is an element with no radius (0 against an empty value).
  • Unsealed path: the only change there is an extra await, and the snapshot wait returns immediately for an unsealed frame. commitKeyframeProps is the only caller, and it awaits.
  • File size and captures: useAnimatedPropertyCommit.ts is 598 lines on the merged result, under the cap, and gsapRuntimeReaders.ts is 126. Before/After captures are present.

Nit: no test covers the new settleGsapSnapshot wait. The test settles before it calls the reader, so removing that await still passes.

Review by Rames

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 0ee98f8 Nov 24, 2026
126 of 127 checks passed
@miguel-heygen
miguel-heygen deleted the fix/studio-sealed-gsap-reads branch November 24, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants